# setup
#编译选项
COMPILE_OPTS = -c -mcpu=cortex-m3 -mthumb  -mlittle-endian  -Wall -g -Werror
#包含的文件目录
INCLUDE_DIRS = -I include -I portable -I ../LibrariesST/inc

OBJ_DIR=obj

CC = arm-none-eabi-gcc
CFLAGS = $(COMPILE_OPTS) $(INCLUDE_DIRS) -D STM32F10X_MD -D VECT_TAB_FLASH 

CXX = arm-none-eabi-g++
CXXFLAGS = $(COMPILE_OPTS) $(INCLUDE_DIRS)

AS = arm-none-eabi-gcc
ASFLAGS = $(COMPILE_OPTS) -c

LD = arm-none-eabi-gcc
LDFLAGS =  -T stm32.ld -Wl,-Map=output.map

OBJCP = arm-none-eabi-objcopy
OBJCPFLAGS = -O binary
#link option
AR = arm-none-eabi-ar
ARFLAGS = cr

FreeRTOS=FreeRTOS.a
FreeRTOS_SRC= croutine.c list.c queue.c tasks.c timers.c event_groups.c  portable/port.c  portable/heap.c
# all
OBJS=$(patsubst %.c,%.o,$(FreeRTOS_SRC))



all:$(OBJS)
	@echo "Building FreeRTOS ..."
	@$(AR) cr FreeRTOS.a $(OBJS)
	@echo "Building FreeRTOS Done!"

%.o:%.S
	@echo CC: $<
	@$(CC) $(CFLAGS) -c $< -o $@
%.o:%.c
	@echo CC: $<
	@$(CC) $(CFLAGS) -c $< -o $@

.PHONY: clean
clean:
	@echo "Clean $@ ..."
	@-rm  *.a $(OBJS)
	@echo "Clean Done ..."
